package com.mgl.movesprite;

import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.mgl.movesprite.game.factory.GameObjectFactory;
import com.mgl.movesprite.game.model.Level;
import com.mgl.util.ButtonSprite;

public class CloseButton extends ButtonSprite{
	
	private BuildPanel panel = null;
	
	public CloseButton(float pX, float pY, ITextureRegion pTextureRegion,
			VertexBufferObjectManager pVertexBufferObjectManager,
			GameObjectFactory gameObjectFactory) {

		super(pX, pY, pTextureRegion, pVertexBufferObjectManager,
				gameObjectFactory);
		}

	@Override
	public void update(float pSecondsElapsed, Level level) {
		
		
	}

	@Override
	public boolean onAreaTouched(final TouchEvent pSceneTouchEvent,
			final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
		
		  // Toggle pause or not                         
        switch(pSceneTouchEvent.getAction()) {
                case TouchEvent.ACTION_DOWN:
                	
                	if(panel == null){
                		System.out.println("Close button, panel era null");                		
                	}else{
                		panel.close();
                	}
                	
                        break;
                case TouchEvent.ACTION_MOVE:
                        break;
                case TouchEvent.ACTION_UP:
                        break;
        }
        return true;
	}

	public BuildPanel getPanel() {
		return panel;
	}

	public void setPanel(BuildPanel panel) {
		this.panel = panel;
	}
	
}
